<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>线性渐变</title>
</head>
<body>
    <div class="box box1">默认情况从上到下</div>
    <div class="box box2"></div>
    <div class="box box3"></div>
    <div class="box box4"></div>
    <div class="box box5"></div>
    <div class="box box6"></div>

</body>
<style>
    .box{
        width: 300px;
        height: 200px;
        border: 1px solid black;
        float: left;
        font-size: 20px;
        margin-left: 50px;
    }

    .box1{
        background-image: linear-gradient(red,yellow,green);
    }
    .box2{
        background-image: linear-gradient(45deg,red,yellow,green);
    }
    .box3{
        background-image: linear-gradient(to right top,red,yellow,green);
    }
</style>

</html>